import {createStore,applyMiddleware} from "redux";
import thunk from "redux-thunk";
import { composeWithDevTools } from 'redux-devtools-extension';
const defalut = {
    name:"张三丰",
    value:"默认值",
    list:[
        "好好学习",
        "天天向上"
    ],
    newsList:[

    ]
}
function reducer(state=defalut,action) {

    if(action.type === "changeValue") {
        const newState = JSON.parse(JSON.stringify(state));
        newState.value = action.value
        console.log(action.value)
        return newState
    }else if(action.type === "changeList") {
        return {
            ...state,
            list: action.list
        }
    }else if(action.type === "changeNewsList"){
        console.log(action)
        return {
            ...state,
            newsList: action.list
        }
    }
    return state
}

const store = createStore(reducer, composeWithDevTools(
    applyMiddleware(thunk),
));

export default store